package com.wu.dms.controller;

import com.wu.common.convertion.result.Result;
import com.wu.common.convertion.result.Results;
import com.wu.dms.dao.entity.ListSong;
import com.wu.dms.dto.ListSongRequestDTO;
import com.wu.dms.service.ListSongService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/listSong")
public class ListSongController {


    private final ListSongService listSongService;


    // 给歌单添加歌曲
    @PostMapping("/add")
    public Result<Boolean> addListSong(@RequestBody ListSongRequestDTO requestParam) {
        listSongService.addListSong(requestParam);
        return Results.success(true);
    }

    // 删除歌单里的歌曲
    @GetMapping("/delete")
    public Result<Boolean> deleteListSong(@RequestParam int songId) {
        listSongService.deleteListSong(songId);
        return Results.success(true);
    }

    // 返回歌单里指定歌单 ID 的歌曲
    @GetMapping("/detail")
    public Result<List<ListSong>> listSongOfSongId(@RequestParam int songListId) {
        return Results.success(listSongService.listSongOfSongId(songListId));
    }

    // 更新歌单里面的歌曲信息
    @PostMapping("/update")
    public Result<Boolean> updateListSongMsg(@RequestBody ListSongRequestDTO requestParam) {
        listSongService.updateListSongMsg(requestParam);
        return Results.success(true);
    }
}
